Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some race conditions #2630

Merged
merged 6 commits into from
Jul 19, 2024
Merged

Fix some race conditions #2630

merged 6 commits into from
Jul 19, 2024

Conversation

HiFiPhile
Copy link
Collaborator

@HiFiPhile HiFiPhile commented May 8, 2024

Describe the PR

  • In cdc_device if read* functions called before tud_ready() transfer will be queued to EP0 cause strange issues.
  • Clear _usbd_dev first to ensure tud_ready() return false before driver clean up.
  • Introduced by work around possible RP2040 erratum #2492, if both DCD_EVENT_BUS_RESET and DCD_EVENT_SETUP_RECEIVED are in the event queue, setup_count is cleared in bus reset, result _usbd_dev.setup_count-- underflow. I think the best fix would be clear the queue on bus reset.
  • Fix STM32F7 FS port build using HS define.

@HiFiPhile HiFiPhile changed the title Fix 2 race conditions Fix some race conditions May 8, 2024
Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add tud_cdc_mounted() and/or tud_cdc_ready() API, and use that in place of tud_ready(). I can make that change, just give me a couple of hours.

- usbd now change _usbd_dev.cfg_num before calling driver's open()
Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, I made some changes, this may not fully address a race, but should make it better (need follow up PR with usb reset later)

  • rebased
  • revert changes to usbd, we will deal with usbreset in interrupt in a separated PR
  • set cfg_num in usbd before calling driver's open(), there is no reason not to do so.
  • also added tud_cdc_n_ready() but not used in this PR.

@hathach hathach merged commit c48d2eb into hathach:master Jul 19, 2024
78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants